﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace KegMonitor
{
    class Helper
    {
        public static byte[] StrToByteArray(string str)
        {
            // Convert a string to an array of ASCII bytes
            System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding();
            return encoding.GetBytes(str);
        }

        public static string ByteArrayToStr(byte[] bytes)
        {
            StringBuilder hexString = new StringBuilder(2);
            for (int i = 0; i < bytes.Length; i++)
            {
                hexString.Append(" ");
                hexString.Append(bytes[i].ToString("X2"));
            }
            return hexString.ToString();
        }

        public static string ConnectionString
        {
            get
            {
                return String.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3};MultipleActiveResultSets=true",
                    Properties.Settings.Default.dbServer,
                    Properties.Settings.Default.dbDatabase,
                    Properties.Settings.Default.dbUser,
                    Properties.Settings.Default.dbPassword);
            }
        }
    }
}
